package team3;

import java.util.List;
import java.util.Random;

/** An AI player that chooses a random legal move.
 */
public class RandomAI extends project2.AI
{
    private Random rand;

    /** Builds a Random AI.
     * @param player The player color for the AI
     */
	public RandomAI(Player player)
	{
		super(player, AI.Difficulty.HARD);
        rand=new Random();
	}

    /** Chooses a random legal move based off the current board state.
     * @param boardState An 8x8 Reversi Board State
     * @param lastMove The last move made by the enemy player.
     * @return A legal move, or BoardState.INVALID_MOVE if no legal moves are available.
     */
	public int[] makeMove(Player[][] boardState, int[] lastMove)
	{
        BoardState state=new BoardState(boardState);
        List<int[]> moves = state.getAvailableMoves(getPlayer());
        if(moves.size()==0)
            return BoardState.INVALID_MOVE;
        return moves.get(rand.nextInt(moves.size()));
	}
}